package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.ActivityAward;
import com.sc.nft.entity.vo.ActivityAwardSaveDetailsVO;
import com.sc.nft.mapper.ActivityAwardMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * (ActivityAward)表Dao层
 *
 * @author 王伟成
 * @since 2023-09-13 15:34:01
 */
@Slf4j
@Repository
public class ActivityAwardDao extends ServiceImpl<ActivityAwardMapper, ActivityAward> {

    public Integer getByActivityBasicsIdGroupByLv(Long activityBasicsId) {
        LambdaQueryWrapper<ActivityAward> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ActivityAward::getActivityBasicsId,activityBasicsId);
        lambdaQueryWrapper.groupBy(ActivityAward::getAwardLv);
        return list(lambdaQueryWrapper).size();
    }


    public List<ActivityAward> getByactivityBasicsIdAndAwardLv(Long activityBasicsId, Integer awardLv) {
        LambdaQueryWrapper<ActivityAward> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ActivityAward::getActivityBasicsId,activityBasicsId);
        lambdaQueryWrapper.eq(ActivityAward::getAwardLv,awardLv);
        return list(lambdaQueryWrapper);
    }

    public List<ActivityAward> getByactivityBasicsId(Long activityBasicsId) {
        LambdaQueryWrapper<ActivityAward> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(ActivityAward::getActivityBasicsId,activityBasicsId);
        return list(lambdaQueryWrapper);
    }

    /**
     * 根据活动配置Id获取奖励内容
     * @param rewardAllocationId
     * @return
     */
    public List<ActivityAwardSaveDetailsVO> getByRewardAllocationId(Long rewardAllocationId) {
        return baseMapper.getByRewardAllocationId(rewardAllocationId);
    }
}
